package com.spark.email.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.mail.javamail.JavaMailSenderImpl;

import java.util.Properties;

/**
 * @Author sc
 * @DATE 2024/5/21 15:38
 * @Description:
 * @Version 1.0
 */
@Configuration
public class MailConfig {

    @Bean
    public JavaMailSenderImpl mailSender() {
        JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();
        javaMailSender.setProtocol("smtp");
        javaMailSender.setHost("smtp.qq.com");
        javaMailSender.setPassword("xvrjhwcekqqmdhaa");
        javaMailSender.setUsername("3203037172@qq.com");
        javaMailSender.setPort(587);

        //加认证机制
        Properties javaMailProperties = new Properties();
        javaMailProperties.put("mail.smtp.auth", "false");
        javaMailProperties.put("mail.smtp.starttls.enable", "false");
        javaMailSender.setJavaMailProperties(javaMailProperties);

        return javaMailSender;
    }

}
